// +----------------------------------------------------------------------
// | BhAdmin [ BhAdmin匠心打造，我们相信，每个伟大的软件都有一个伟大的故事 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020~2023 https://www.bhadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed BhAdmin并不是自由软件，未经许可不能去掉BhAdmin相关版权
// +----------------------------------------------------------------------
// | Author: BAIHU  <admin@bhadmin.cn>
// +----------------------------------------------------------------------

import http from '@/utils/http'
import type { TableData } from '@arco-design/web-vue/es/table/interface';

/**
 * 查询请求体
 */
export interface QueryRequest {
    name?: string;
}

export interface PageQueryRequest extends QueryRequest, PageQuery {}


/**
 * 查询响应
 */
export interface QueryResponse extends TableData {
    id: number;
    name: string;
    status: number;
    sort: number;
    create_time?: number;
    update_time?: number;
    mark?: number;
}

/**
 * 更新请求体
 */
export interface UpdateRequest {
    id?: number;
    status?: number;
    sort?: number;
    name?: string;
}

/**
 * 查询列表(分页)
 */
export function getList(params: QueryRequest)  {
    return http.get<PageRes<QueryResponse[]>>('/admin/level/index', params)
}

/**
 * 修改状态
 */
export function updateRowStatus(request: UpdateRequest) {
    return http.post('/admin/level/status', request);
}


/**
 * 通过id数组批量删除数据
 */
export function batchDeleteRows(idList: Array<number>) {
    return http.post('/admin/level/delete', {
        id: idList,
    });
}

/**
 * 通过 id 删除数据
 */
export function deleteRows(id: number) {
    return http.post('/admin/level/delete', { id })
}

/**
 * 通过 id 新增更新数据
 */
export function updateRows(request: UpdateRequest) {
    return http.put('/admin/level/edit', request);
}

